﻿using B.S.BaseData.suyuan.ApiRead.Account.Command;
using B.S.BaseData.suyuan.InforStances.Interface;
using B.S.BaseData.Suyuan.Command;
using B.S.BaseData.Suyuan.Dommain;
using MediatR;

namespace B.S.BaseData.suyuan.ApiRead.Account.CommandHeader
{
    public class GetShopCommandHeader : IRequestHandler<GetShopCommand, ApiResult<IList<ShopMondel>>>
    {
        private readonly IBaseRepository<ShopMondel> ShopBase;

        public GetShopCommandHeader(IBaseRepository<ShopMondel> shopBase)
        {
            ShopBase = shopBase;
        }
        /// <summary>
        /// 显示商品
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public Task<ApiResult<IList<ShopMondel>>> Handle(GetShopCommand request, CancellationToken cancellationToken)
        {
            ApiResult<IList<ShopMondel>> result=new ApiResult<IList<ShopMondel>>();
            result.Code = APIEnum.显示成功;
            result.Msg=APIEnum.显示成功.ToString();
            var list = ShopBase.IQueryEntity().Result;
            result.data = list.ToList();
            return Task.FromResult(result);
        }
    }
}
